<?php get_instance()->view('common/header');?>
<style>
    .box.box-info {
        border-top-color: #e6e6e6;
    }
	.box-header.with-border {
		border-bottom: 1px solid #f4f4f4;
	}
	.box-body {
		border-top-left-radius: 0;
		border-top-right-radius: 0;
		border-bottom-right-radius: 3px;
		border-bottom-left-radius: 3px;
		padding: 10px;
	}
	.box-header {
		color: #444;
		display: block;
		padding: 10px;
		position: relative;
	}
	.box.box-primary {
		border-top-color: #3c8dbc;
	}
	.box {
		position: relative;
		border-radius: 3px;
		background: #ffffff;
		border-top: 3px solid #d2d6de;
		margin-bottom: 20px;
		width: 100%;
		box-shadow: 0 1px 1px rgba(0,0,0,0.1);
	}
	#list-table>thead>tr:nth-child(2)>th{
		font-size: 12px;
		font-weight: 700;
		color:#666;
	}
	#list-table>tbody>tr>td{
		color: #808080;
	}
	tbody>tr>td:nth-child(1), thead>tr>th:nth-child(1) {
		width: auto !important;
		white-space: pre-line !important;
	}
	tbody>tr>td:nth-child(2), thead>tr>th:nth-child(2) {
		width: auto !important;
		white-space: pre-line !important;
	}
	td,th{
		vertical-align: middle !important;
	}
    #list-table td,th{text-align: center;}
</style>
<div class="page-container wrapper">
	<!-- BEGIN SIDEBAR -->
	<?php get_instance()->view('common/sidebar');?>
	<!-- END SIDEBAR -->
	<!-- BEGIN CONTENT -->
	<div class="page-content-wrapper">
		<div class="page-content" style="min-height:1200px !important">
			<!-- BEGIN PAGE HEADER-->
            <div class="row">
                <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                    <div class="dashboard-stat blue">
                        <div class="visual">
                            <img src="<?php echo $this->staticUrl;?>img/statistics1.png" alt="">
                        </div>
                        <div class="details">
                            <div class="number reality_amount"><?php echo $info['reality_amount']?></div>
                            <div class="desc">平台销售总额</div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                    <div class="dashboard-stat green">
                        <div class="visual">
                            <img src="<?php echo $this->staticUrl;?>img/statistics2.png" alt="">
                        </div>
                        <div class="details">
                            <div class="number total"><?php echo $info['total']?></div>
                            <div class="desc">平台总订单量</div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                    <div class="dashboard-stat purple">
                        <div class="visual">
                            <img src="<?php echo $this->staticUrl;?>img/statistics3.png" alt="">
                        </div>
                        <div class="details">
                            <div class="number expenditure"><?php echo $expenditure?></div>
                            <div class="desc">平台支出总额</div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                    <div class="dashboard-stat yellow">
                        <div class="visual">
                            <img src="<?php echo $this->staticUrl;?>img/statistics4.png" alt="">
                        </div>
                        <div class="details">
                            <div class="number profit"><?php echo $info['reality_amount']-$expenditure?></div>
                            <div class="desc">平台利润</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="box box-info">
                        <div class="box-header with-border">
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="col-xs-5">
                                        <div class="input-group margin">
                                            <div class="input-group-addon">
                                                选择时间  <i class="fa fa-calendar"></i>
                                            </div>
                                            <input type="text" class="form-control form-filter pull-right" name="timegap" id="start_time">
                                        </div>
                                        <div id="statistics" style="display:none"></div>
                                    </div>
                                    <div class="col-xs-2 col-xs-offset-5"><input class="btn btn-block btn-info margin add-btn" type="submit" value="确定"></div>
                                </div>
                            </div>
                        </div>
<!--                        <div class="box-body">-->
<!--                            <div class="row">-->
<!--                                <div class="col-sm-8 col-xs-8">-->
<!--                                    备注：1.此表显示的是一定时间内平台资金信息-->
<!--                                </div>-->
<!--                            </div>-->
<!--                        </div>-->
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title" style="height: 32px;line-height: 32px;"><i class="fa fa-list"></i> 运营概览
                                <?php if(adminAuthority('admin-export', 'statistics')):?>
                                    <a href="javascript:;" target="_parent" class="btn btn-info margin fr export" style="color: #fff"> 导出</a>
                                <?php endif;?>
                            </h3>
                        </div>
                        <div class="panel-body">
                            <table id="list-table" class="table table-bordered table-striped" >
                                <thead>
                                <tr>
                                    <th>时间</th>
                                    <th>订单商品总额</th>
                                    <th>订单优惠总额</th>
                                    <th>物流总额</th>
                                    <th>支出</th>
                                    <th>平台沉淀资金</th>
                                    <th>查看明细</th>
                                </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
		</div>
	</div>
</div>
<!-- END CONTENT -->
</div>
<script type="text/javascript">
	$(document).ready(function() {
        datatable_init({
            "sDom": "<'row'<'col-md-5 col-sm-12'<'table-group-actions pull-right'>>r><'table-scrollable't><'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'>r>>",
            src: $("#list-table"),
            sAjaxSource: "<?php echo getUrl('statistics/admin/getList');?>",
            bSort:false
        });

		$('#start_time').daterangepicker({
			format:"YYYY-MM-DD",
			singleDatePicker: false,
			showDropdowns: true,
			minDate:'2016-01-01',
			maxDate:'2030-01-01',
//            startDate:'<?php //echo $startTime?>//',
//            endDate: '<?php //echo $endTime?>//', //设置结束器日期
			showWeekNumbers: true,
			timePicker: false,
			timePickerIncrement: 1,
			timePicker12Hour: true,
			ranges: {
				'最近30天': [moment().subtract('days', 29), moment()],
				'上一个月': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')]
			},
			opens: 'right',
			buttonClasses: ['btn btn-default'],
			applyClass: 'btn-small btn-primary',
			cancelClass: 'btn-small',
			locale : {
				applyLabel : '确定',
				cancelLabel : '取消',
				fromLabel : '起始时间',
				toLabel : '结束时间',
				customRangeLabel : '自定义',
				daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
				monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
				firstDay : 1
			}
		});

        $(".add-btn").click(function () {
            var vl = $("[name='timegap']").val();
            if (!vl.length){
                show_message({status:0, message:'请选择时间'});
                return false;
            }
            $("#list-table").dataTable().fnDraw(true);
            var url = '<?php echo getUrl("statistics/admin/getStatistics")?>';
            l_blockUI();
            $.post(url,{timegap:vl},function(data){
                $(".reality_amount").html(data.data.reality_amount);
                $(".total").html(data.data.total);
                $(".expenditure").html(data.data.expenditure);
                $(".profit").html(data.data.profit);
                App.unblockUI();
            }, 'json');
        });


        $(".export").click(function () {
            var vl = $("[name='timegap']").val();
            if (!vl.length){
                show_message({status:0, message:'请选择时间'});
                return false;
            }
            window.location.href = '<?php echo getUrl("statistics/admin/export")?>?timegap='+vl;
        });
	});
</script>
</body>
</html>